<template>
  
    <ul class="todo-main" v-show="todos.length">
    <!-- <UserItem v-for="(todo) in todos" :key="todo.id" :id="todo.id"  :title="todo.title" :done="todo.done"/> -->
        <!-- <transition-group
            appear
            name="todo" 
        > -->
        <transition-group
            appear
            name="animate__animated animate__bounce" 
            enter-active-class="animate__flip"
            leave-active-class="animate__hinge"
        >
            <UserItem 
                v-for="(todo) in todos" 
                :key="todo.id" 
                :todo="todo"
            />
        </transition-group>
    </ul>
        
</template>

<script>
// 引入css样式库
import 'animate.css'

import UserItem from './UserItem.vue'

    export default {
        name:'UserList',
        
        // 注册组件
        components:{
            UserItem,
        },
        props:['todos']
    }
</script>

<style scoped>

    /* 如下样式与老师的一致，但运行结果使用的是第三方css样式做测试 */
    .todo-enter-active{
        animation:atbian 0.5s;
    }

    .todo-leave-active{
        animation: atbian 0.5s reverse;
    }

    @keyframes atbian {
        from{
            transform: translateX(100%);
        }
        to{
            transform: translateX(0px);
        }

    }


    /*main*/
    .todo-main {
    margin-left: 0px;
    border: 1px solid #ddd;
    border-radius: 2px;
    padding: 0px;
    }

    .todo-empty {
    height: 40px;
    line-height: 40px;
    border: 1px solid #ddd;
    border-radius: 2px;
    padding-left: 5px;
    margin-top: 10px;
    }
</style>